﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client;
using Raven.Client.Document;

namespace SportsStore.DataBaseInfrastructure
{
    public class RavenDataBaseConnection : IDataBase
    {
        private readonly Uri documentUri;
        private IDocumentStore store;
        public RavenDataBaseConnection(string connectionUri)
        {
            if (connectionUri == string.Empty)
                throw new ArgumentException("Connection URI cannot be Empty");
            documentUri = new Uri(connectionUri);
        }

        public IDocumentStore Connect()
        {
            if (store == null)
                store = new DocumentStore { Url = documentUri.OriginalString };
            store.Initialize();

            return store;
        }
    }
}
